package com.sg.common;

import java.io.Serializable;

import com.sg.fileService.common.ErrorCode;

/**
 * 
	 * ClassName: ResultModel <br/>  
	 * Reason:controller返回前端的json数据的封装DTO <br/>  
	 * date: 2017年12月11日 上午9:51:04 <br/>  
	 *  
	 * @author XZK  
	 * @version   
	 * @since JDK 1.8
 */
public class ResultModel implements Serializable{
	
	private static final long serialVersionUID = 8516278492114207302L;
	/**
	 * 是否操作成功
	 */
	private boolean isSuccess;
	
	/**
	 * 错误码
	 */
	private String errorCode;
	
	/**
	 * 错误信息
	 */
	private String message;
	/**
	 * 返回的响应数据
	 */
	private Object data;
	
	public ResultModel(){
		this.isSuccess = false;
		this.errorCode = "";
		this.message = "";
		this.data = null;
	}
	
	/**
	 * 
		 * Creates a new instance of ResultModel.  
		 *  
		 * @param isSuccess 操作是否成功
	 */
	public ResultModel(boolean isSuccess){
		this.isSuccess = isSuccess;
		this.errorCode = "";
		this.message = "";
		this.data = null;
	}
	
	/**
	 * 
		 * Creates a new instance of ResultModel.  
		 *  
		 * @param isSuccess 是否操作成功
		 * @param errorCode 错误码
	 */
	public ResultModel(boolean isSuccess,String errorCode){
		this.isSuccess = isSuccess;
		this.errorCode = errorCode;
		this.message = "";
		this.data = null;
	}
	
	/**
	 * 
		 * Creates a new instance of ResultModel.  
		 *
		 * @param error 错误码
	 */
	public ResultModel(ErrorCode error){
		this.isSuccess = false;
		this.errorCode = error.getErrorCodeValue();
		this.message = error.getCodeMessage();
		this.data = null;
	}
	
	/**
	 * 
		 * Creates a new instance of ResultModel.  
		 *  
		 * @param isSuccess 是否操作成功
		 * @param errorCode 错误码
		 * @param message 错误信息
	 */
	public ResultModel(boolean isSuccess,String errorCode,String message){
		this.isSuccess = isSuccess;
		this.errorCode = errorCode;
		this.message = message;
		this.data = null;
	}
	
	/**
	 * 
		 * Creates a new instance of ResultModel.  
		 *  
		 * @param errorCode 错误码
		 * @param message 错误信息
	 */
	public ResultModel(String errorCode,String message){
		this.isSuccess = false;
		this.errorCode = errorCode;
		this.message = message;
		this.data = null;
	}
	/**
	 * 
		 * Creates a new instance of ResultModel.  
		 *  
		 * @param isSuccess 是否操作成功
		 * @param errorCode 错误码
		 * @param message 错误信息
		 * @param data 返回数据
	 */
	public ResultModel(boolean isSuccess,String errorCode,String message,Object data){
		this.isSuccess = isSuccess;
		this.errorCode = errorCode;
		this.message = message;
		this.data = data;
	}
	
	public boolean getIsSuccess() {
		return isSuccess;
	}

	public void setIsSuccess(boolean isSuccess) {
		this.isSuccess = isSuccess;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
}
